package com.dongdongshop.service.impl;

import com.dongdongshop.mapper.TbPersonMapper;
import com.dongdongshop.model.TbPerson;
import com.dongdongshop.model.TbPersonExample;
import com.dongdongshop.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PersonServiceImpl implements PersonService {

    @Autowired
    private TbPersonMapper personMapper;

    @Override
    public TbPerson getUserByName(String personname) {
        TbPersonExample example = new TbPersonExample();
        TbPersonExample.Criteria criteria = example.createCriteria();
        criteria.andNameEqualTo(personname);
        List<TbPerson> list = personMapper.selectByExample(example);
        return list == null || list.isEmpty() ? null :list.get(0);
    }
}
